<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>您好Springboot</title>

<!-- 1.导入函数类库 -->
<script src="../js/jquery-3.4.1.min.js"></script>
<script type="text/javascript">
	
	//让JS页面加载完成,之后执行JS
	$(function(){
		/* 原生ajax写法 jquery编程特点：函数式编程 
		   需求：传递id=100，name=猫
		   参数写法：1）data:{"id":100,"name":"猫"}
					2）data:"id=100&name=猫"
		*/
		$.ajax({
			url:"/findAjax",
			type:"get",
			data:{"id":100,"name":"猫"},
			success:function(result){
				for(let user of result){
					let id=user.id;
					let name=user.name;
					let age=user.age;
					let sex=user.sex;
					let tr="<tr><td>"+id+"</td><td>"+name+"</td><td>"+age+"</td><td>"+sex+"</td></tr>";
					$("#tab1").append(tr);
				}
			},
			error:function(result){
				
			},
			cache:true,
			async:true
		});
	})
</script>


</head>
<body>
	<table id="tab1"  border="1px" width="65%" align="center">
		<tr>
			<td colspan="6" align="center"><h3>学生信息</h3></td>
		</tr>
		<tr>
			<th>编号</th>
			<th>姓名</th>
			<th>年龄</th>
			<th>性别</th>
		</tr>
	</table>
</body>
</html>